<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/style.css" />
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.SuperSlide.2.1.1.js"></script>
<!--/meta 作为公共模版分离出去-->
<title>商家上传</title>
</head>
<body>
<article class="page-container">
	<form action="<?php url('business/image')?>" method="post" class="form form-horizontal" id="form-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">原图片：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <div class="picScroll-left">
                    <div class="hd">
                        <a class="next"></a>
                        <ul></ul>
                        <a class="prev"></a>
                        <span class="pageState"></span>
                    </div>
                    <div class="bd">
                        <ul class="picList">
                            <?php if(empty($info['image'])){ echo '<span style="color:red">暂时未上传咯！</span>';}else{?>
                            <?php foreach($info['image'] as $k=>$v){?>
                            <li>
                                <div class="pic"><img src="<?php echo $v['thumb']?>" /></div>
                                <div class="title">图片<?php echo $k+1?></div>
                            </li>
                            <?php } }?>
                        </ul>
                    </div>
                </div>
                <script type="text/javascript">
                    jQuery(".picScroll-left").slide({titCell:".hd ul",mainCell:".bd ul",autoPage:true,effect:"left",autoPlay:true,vis:4,trigger:"click"});
                </script>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">新上传：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <div class="container1">
                    <!--    照片添加    -->
                    <div class="z_photo">
                        <div class="z_file">
                            <input type="file" name="image[]" id="file" multiple="multiple" onchange="imgChange('z_photo','z_file');"  style="width: 100px; height: 100px; opacity: 0"/>
                        </div>
                    </div>
                    <!--遮罩层-->
                    <div class="z_mask">
                        <!--弹出框-->
                        <div class="z_alert">
                            <p>确定要删除这张图片吗？</p>
                            <p>
                                <span class="z_cancel">取消</span>
                                <span class="z_sure">确定</span>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input type="hidden" name="id" value="<?php echo $info['id']?>">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/admin/js/layer.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="/static/admin/js/validate-methods.js"></script>
<script type="text/javascript" src="/static/admin/js/messages_zh.js"></script>
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
function imgChange(obj1, obj2) {
    //获取点击的文本框
    var file = document.getElementById("file");
    //存放图片的父级元素
    var imgContainer = document.getElementsByClassName(obj1)[0];
    //获取的图片文件
    var fileList = file.files;
    //文本框的父级元素
    var input = document.getElementsByClassName(obj2)[0];
    var imgArr = [];

    //遍历获取到得图片文件
    for (var i = 0; i < fileList.length; i++) {
        var imgUrl = window.URL.createObjectURL(file.files[i]);
        imgArr.push(imgUrl);
        var img = document.createElement("img");
        img.setAttribute("src", imgArr[i]);
        var imgAdd = document.createElement("div");
        imgAdd.setAttribute("class", "z_addImg");
        imgAdd.appendChild(img);
        imgContainer.appendChild(imgAdd);
    };
    imgRemove();
};
function imgRemove() {
    var imgList = document.getElementsByClassName("z_addImg");
    var mask = document.getElementsByClassName("z_mask")[0];
    var cancel = document.getElementsByClassName("z_cancel")[0];
    var sure = document.getElementsByClassName("z_sure")[0];
    for (var j = 0; j < imgList.length; j++) {
        imgList[j].index = j;
        imgList[j].onclick = function() {
            var t = this;
            mask.style.display = "block";
            cancel.onclick = function() {
                mask.style.display = "none";
            };
            sure.onclick = function() {
                mask.style.display = "none";
                t.style.display = "none";
            };

        }
    };
};
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	$("#form-add").validate({

		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			var options = {
				success: function (data) {
					if(data.code == 0){
						layer.msg(data.msg,{icon:1,time:1000});
						setInterval("closeWindow()",1000);
					}else{
						layer.msg(data.msg,{icon:5,time:1000});
					}
				}
			};
			$(form).ajaxSubmit(options);
		}
	});
});
function closeWindow() {
	var index = parent.layer.getFrameIndex(window.name);
	window.parent.location.reload();
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>